package collection;
 
import java.util.*;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;
 

public class Test {
 
    public static void main(String[] args) {



        int o = 0;
        for (int a = 0;a<10;a++){

            for (int b = 0;b<10;b++){
                for (int c = 0;c<10;c++){
                    for (int d = 0;d<10;d++){
                        o++;
                    }
                }
            }
        }
        System.out.println(o);




        List<Map<String,String>> map1 = new ArrayList<>();
        for (int i = 0;i<10;i++){
            Map<String, String> map = new HashMap<>();
            if (i<2) {
                map.put("age", "18"+i);
                map.put("name", "zhangsan"+i);
                map.put("sex","0"+i);
            }else {
                map.put("age", "18"+i);
                map.put("name", "lisi"+i);
                map.put("sex","0"+i);
            }
            map1.add(map);
        }

        List<Map<String,String>> map2 = new ArrayList<>();
        for (int i = 0;i<10;i++){
            Map<String, String> map = new HashMap<>();
            if (i<2) {
                map.put("age", "18"+i);
                map.put("name", "zhangsan"+i);
                map.put("sex","0"+i);
            }else {
                map.put("age", "18"+i);
                map.put("name", "wangwu"+i);
                map.put("sex","0"+i);
            }
            map2.add(map);
        }

        //交集

        List<Map<String, String>> collect = map1.stream().filter(item -> map2.stream().map(up -> up.get("name").concat(up.get("age")).concat(up.get("sex"))).collect(toList()).contains(item.get("name").concat(item.get("age")).concat(item.get("sex")))).collect(toList());
        //collect.stream().forEach(System.out::println);


        //差集（map1--map2）

        List<Map<String, String>> collect1 = map1.stream().filter(item -> !map2.stream().map(up -> up.get("name").concat(up.get("age")).concat(up.get("sex"))).collect(toList()).contains(item.get("name").concat(item.get("age")).concat(item.get("sex")))).collect(toList());
        //collect1.stream().forEach(System.out::println);

        //差集（map2 -- map1）
        List<Map<String, String>> collect2 = map2.stream().filter(item -> !map1.stream().map(up -> up.get("name").concat(up.get("age")).concat(up.get("sex"))).collect(toList()).contains(item.get("name").concat(item.get("age")).concat(item.get("sex")))).collect(toList());
        collect2.stream().forEach(System.out::println);



//        List<String> list1 = new ArrayList<String>();
//        list1.add("1");
//		list1.add("2");
//		list1.add("3");
//		list1.add("5");
//		list1.add("6");
//
//        List<String> list2 = new ArrayList<String>();
//        list2.add("2");
//		list2.add("3");
//		list2.add("7");
//		list2.add("8");
//
//        // 交集
//        List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(toList());
//        System.out.println("---交集 intersection---");
//        intersection.parallelStream().forEach(System.out :: println);
//
//        // 差集 (list1 - list2)
//        List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
//        System.out.println("---差集 reduce1 (list1 - list2)---");
//        reduce1.parallelStream().forEach(System.out :: println);
//
//        // 差集 (list2 - list1)
//        List<String> reduce2 = list2.stream().filter(item -> !list1.contains(item)).collect(toList());
//        System.out.println("---差集 reduce2 (list2 - list1)---");
//        reduce2.parallelStream().forEach(System.out :: println);
//
//        // 并集
//        List<String> listAll = list1.parallelStream().collect(toList());
//        List<String> listAll2 = list2.parallelStream().collect(toList());
//        listAll.addAll(listAll2);
//        System.out.println("---并集 listAll---");
//        listAll.parallelStream().forEachOrdered(System.out :: println);
//
//        // 去重并集
//        List<String> listAllDistinct = listAll.stream().distinct().collect(toList());
//        System.out.println("---得到去重并集 listAllDistinct---");
//        listAllDistinct.parallelStream().forEachOrdered(System.out :: println);
//
//        System.out.println("---原来的List1---");
//        list1.parallelStream().forEachOrdered(System.out :: println);
//        System.out.println("---原来的List2---");
//        list2.parallelStream().forEachOrdered(System.out :: println);
 
    }
}